import * as THREE from "three";

function createMesh(color, x) {
	const geometry = new THREE.DodecahedronGeometry(1);
	const material = new THREE.MeshBasicMaterial({
		color: color,
	});
	const mesh = new THREE.Mesh(geometry, material);
	mesh.position.x = x;
	return mesh;
}

const mesh = createMesh("orange", 0);
const mesh2 = createMesh("skyblue", 5);
const mesh3 = createMesh("lightgreen", -5);

const group = new THREE.Group();
group.add(mesh);
group.add(mesh2);
group.add(mesh3);

const loader = new THREE.TextureLoader();
function createSprite(x, y) {
	const texture = loader.load("/assets/image/sprite.png");
	const material = new THREE.SpriteMaterial({
		map: texture,
	});
	const sprite = new THREE.Sprite(material);
	sprite.position.set(x, y, 0);
	return sprite;
}
const sprite1 = createSprite(0, 1.5);
const sprite2 = createSprite(5, 1.5);
const sprite3 = createSprite(-5, 1.5);
group.add(sprite1);
group.add(sprite2);
group.add(sprite3);

const snowGroup = new THREE.Group();
const load1 = new THREE.TextureLoader();
const texture1 = load1.load("/assets/image/snow.png");
const spriteMaterial1 = new THREE.SpriteMaterial({
	map: texture1,
})
function createSnow() {
	for (let i = 0; i < 10000; i++) {
		const sprite = new THREE.Sprite(
			spriteMaterial1
		);
		const x = 1000 * Math.random();
		const y = 1000 * Math.random();
		const z = 1000 * Math.random();
		sprite.position.set(x, y, z);
		snowGroup.add(sprite);
	}
}
createSnow();

export { group, snowGroup };
